package main

import (
	"encoding/json"
	"fmt"
	"unicode"
)

const (
	minNameLen = 2
	maxNameLen = 16
)

func checkGuildName(name string) error {
	nameWords := []rune(name)
	lenName := len(nameWords)
	if lenName < minNameLen || lenName > maxNameLen {
		return fmt.Errorf("length must >= %d and <= %d", minNameLen, maxNameLen)
	}
	var hasLetter bool
	for _, w := range nameWords {
		if unicode.IsLetter(w) {
			hasLetter = true
			break
		}
	}
	if !hasLetter {
		// 至少要包含1个字母和1个数字
		return fmt.Errorf("must have 1 letter or more")
	}
	return nil
}

type value1 struct {
	I int
}

func newValue1(i int) value1 {
	return value1{
		I: i,
	}
}

type value2 struct {
	value1
}

func newValue2(i int) *value2 {
	return &value2{
		value1: newValue1(i),
	}
}

func main() {
	//var num = 1
	//for i := 1; i < 10000; i++ {
	//	fmt.Printf("%d mod %d = %d\n", i, num, i%num)
	//}

	m := map[int][]*value2{
		1: {
			newValue2(1),
			newValue2(2),
		},
	}

	v, _ := m[1]
	v[0].I = 2
	v = nil

	ba, _ := json.Marshal(m)

	fmt.Printf("%s\n", ba)
}
